package com.alan.android.sqlite.builder;

import android.content.Context;

import com.alan.android.sqlite.AndroidSqlite;
import com.alan.android.sqlite.DatabaseHelper;

import java.util.List;

public class AndroidDatabaseBuilder {

    private String name;

    private int version;

    private Context context;

    private List<Class> tableList;

    private AndroidDatabaseBuilder(Context context) {
        this.context = context;
    }

    public static AndroidDatabaseBuilder create(Context context) {
        return new AndroidDatabaseBuilder(context);
    }

    public AndroidDatabaseBuilder setName(String name) {
        this.name = name;
        return this;
    }

    public AndroidDatabaseBuilder setVersion(int version) {
        this.version = version;
        return this;
    }

    public AndroidDatabaseBuilder setTableList(List<Class> tableList) {
        this.tableList = tableList;
        return this;
    }

    public AndroidSqlite build() {
        DatabaseHelper databaseHelper = new DatabaseHelper(context, name, version, tableList);
        return new AndroidSqlite(databaseHelper.getWritableDatabase());
    }
}
